<!-- 图文集-样式 -->
<template>
    <el-collapse modelValue="1">
        <el-collapse-item title="组件设置" name="1">
            <layout-pane label="样式">
                <div
                    :class="{'active': mode === 0 }"
                    class="list-mode"
                    @click="mode = 0"
                >
                    <div class="first-content">
                        <div class="first-box">
                            <div class="first-gray"></div>
                            <div class="first-line">
                                <span></span>
                                <span></span>
                            </div>
                        </div>
                        <div class="first-box">
                            <div class="first-gray"></div>
                            <div class="first-line">
                                <span></span>
                                <span></span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div
                    :class="{'active': mode === 1 }"
                    class="list-mode"
                    @click="mode = 1"
                >
                    <div class="second-content">
                        <div class="second-box">
                            <span></span>
                        </div>
                        <div class="second-box">
                            <span></span>
                        </div>
                    </div>
                </div>
            </layout-pane>
        </el-collapse-item>
    </el-collapse>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
import LayoutPane from '@/components/setting-pane/layout-pane'
export default defineComponent({
    name: 'ListMode',
    components: {
        LayoutPane
    },
    props: {
        widget: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props) {
        const { widget } = toRefs(props)

        const mode = computed({
            get: () => widget.value.widgetData.eles.customFeature.mode,
            set: val => {
                const customFeature = widget.value.widgetData.eles.customFeature
                customFeature.mode = val
                if (val === 0) {
                    customFeature.lineHeight = 60
                    customFeature.imgHeight = 60
                    customFeature.imgWidth = 60
                } else if (val === 1) {
                    customFeature.lineHeight = 190
                    customFeature.imgHeight = 140
                    customFeature.imgWidth = 320
                }
            }
        })

        return {
            widget,
            mode
        }
    }
})
</script>

<style lang="less" scoped>
.list-mode {
    display: inline-block;
    width: 84px;
    height: 64px;
    box-sizing: border-box;
    border: 1px solid var(--edit-border-color-darker);
    padding: 6px 7px;
    vertical-align: top;
    cursor: pointer;
    & + .list-mode {
        margin-left: 12px;
    }
    &.active {
        border: 1px solid var(--edit-color-primary);
    }
    & > div {
        background-color: var(--edit-border-color);
        height: 100%;
    }
    .first-content {
        display: flex;
        flex-direction: column;
        padding: 5px;
        box-sizing: border-box;
        .first-box {
            width: 100%;
            height: 50%;
            display: flex;
            &:first-child {
                border-bottom: 1px solid var(--edit-text-color-disabled);
                padding-bottom: 3px;
            }
            &:last-child {
                padding-top: 4px;
            }
            .first-gray {
                width: 15px;
                height: 15px;
                background-color: var(--edit-text-color-disabled);
            }
            .first-line {
                display: flex;
                flex-direction: column;
                height: 16px;
                padding: 2px 4px;
                justify-content: space-between;
                box-sizing: border-box;
                span {
                    display: inline-block;
                    width: 35px;
                    height: 2px;
                    background-color: var(--edit-text-color-disabled);
                    &:last-child {
                        width: 25px;
                    }
                }
            }
        }
    }
    .second-content {
        display: flex;
        flex-direction: column;
        padding: 5px 8px;
        box-sizing: border-box;
        text-align: center;
        line-height: initial;
        .second-box {
            &:first-child {
                border-bottom: 1px solid var(--edit-text-color-disabled);
                padding-bottom: 2px;
            }
            &:last-child {
                padding-top: 4px;
            }
            span {
                background-color: var(--edit-text-color-disabled);
                width: 100%;
                height: 14px;
                display: inline-block;
            }
        }
    }
}
</style>